using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Diagnostics.Contracts;

namespace PEM
{
    internal partial class MainWindowViewModel
    {
        public class ExitAppCommand : ICommand
        {
            #region Constructor

            public ExitAppCommand(MainWindowViewModel model)
            {
                Contract.Requires(model != null);
                _model = model;
            }

            #endregion // Constructor

            #region ICommand Members

            public bool CanExecute(object parameter)
            {
                return true;
            }

            public event EventHandler CanExecuteChanged;

            public void Execute(object parameter)
            {
                _model.ExitApp();
            }

            #endregion

            #region Fields

            private MainWindowViewModel _model;

            #endregion // Fields
        }

        public class AppCommandsCollection
        {
            #region Properties

            public ExitAppCommand ExitApp
            {
                get;
                private set;
            }

            #endregion // Properties

            #region Constructor

            public AppCommandsCollection(MainWindowViewModel model)
            {
                ExitApp = new ExitAppCommand(model);
            }

            #endregion // Constructor
        }

        public AppCommandsCollection AppCommands
        {
            get;
            private set;
        }

        public void ExitApp()
        {
            _window.Close();
        }
    }
}
